<?php get_header(); ?>
<div id="colLeft">
<?php
$wpq = array (post_type =>'san-pham','taxonomy'=>'nhom-san-pham');
$query = new WP_Query ($wpq);
?>
<table id="product_list" cellpadding="0">
	<tr>
<?
$i = 0;
if (have_posts())
{
while ( have_posts()) : the_post(); ?>

	<td class="td_hover"><div class="product_detail">
			<a href="<?php the_permalink() ?>" title="<?php the_title();?>"><img src="<? if(get_post_meta($post->ID,'primary_image',true) != '') echo get_post_meta($post->ID,'primary_image',true); else echo get_bloginfo('url').'/images/no_image.jpg'; ?>" alt="<?php the_title();?>" title="<?php the_title();?>" /></a>
			<a href="<?php the_permalink() ?>" title="<?php the_title();?>" ><?php the_title();?></a>
            <? 
			if(get_post_meta($post->ID,'giamgia',true) != ''){
			?>
            	<p class="jk-discount"><?= format_number(get_post_meta($post->ID,'giaban',true),0).' VNĐ'; ?></p>
                <p class="jk-price"><? if(get_post_meta($post->ID,'giaban',true) != '') 
									   {
										   $gia = (int)get_post_meta($post->ID,'giaban',true) - (int)get_post_meta($post->ID,'giamgia',true);
										   echo format_number($gia,0).' VNĐ';
									   }
									   else echo 'Liên hệ';?></p>
            <? 
			}else{
			?>	
                
                <p class="jk-price"><? if(get_post_meta($post->ID,'giaban',true) != '') echo format_number(get_post_meta($post->ID,'giaban',true),0).' VNĐ'; else echo 'Liên hệ';?></p>
           <?
			}
            ?>
        </div>
    </td>
	<?
    	
		if(($i-3) % 4 == 0){
	?>
		</tr>
        <tr><td colspan="7" class="space_row"></td></tr>
		<tr>
  
    <?php
		}
		else
		{
			?>
            	<td class="space_col"></td>
            <?
		}
 
	$i++;
	
endwhile; 
	if($i == 1)
		echo '<td width=25%></td><td width=25%></td><td width=25%></td>';
	if($i == 2)
		echo '<td width=25%></td><td width=25%></td>';
	if($i == 3 )
		echo '<td width=25%></td>';

}
else{
?>
	<p class="jk_err">Hàng đã hết. Trở về trang <a href="<? bloginfo('url'); ?>"><? bloginfo('name'); ?></a></p>

<?

}
?>
</tr>
</table>
</div>
<?php get_sidebar(); ?>	
<?php get_footer(); ?>